package com.zk.cq.send.message;

import lombok.Getter;

import java.util.ArrayList;

/**
 */
public class MessageBuilder {
    @Getter
    private ArrayList<Object> components = new ArrayList<>();

    public static MessageBuilder builder() {
        return new MessageBuilder();
    }
    /**
     * 添加一个子消息
     *
     * @param object Component
     * @return 这个实例
     */
    public MessageBuilder add(Object object) {
        components.add(object);
        return this;
    }

    /**
     * 换行
     *
     * @return 这个实例
     */
    public MessageBuilder newLine() {
        return this.add("\n");
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();

        components.forEach(stringBuilder::append);

        return stringBuilder.toString();
    }
}